﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel.Composition;

namespace Kooboo.Commerce.Repositories
{
    [Export(typeof(IProductImage))]
    partial class ProductImage:Entity ,IProductImage
    {
        IProduct _product;
        IProduct IProductImage.Product
        {
            get
            {
                if (_product == null)
                {
                    _product = this.DataContext.Products
                        .FirstOrDefault(it => it.Id == ProductId);
                }
                return _product;
            }
            set
            {
                if (value == null)
                {
                    throw new NullReferenceException("Product is null for PrdouctImage" + this.Id);
                }
                this._product = value;


                this.ProductId = value.Id;
            }
        }
    }
}
